package com.cf.mvp.sample;

import android.os.Bundle;

import androidx.annotation.Nullable;

import com.cf.mvp.base.BaseView;
import com.cf.mvp.mvp.annotation.FunPresenter;
import com.cf.mvp.mvp.annotation.Presenter;
import com.cf.mvp.sample.mvp.contract.MainContract;
import com.cf.mvp.sample.mvp.contract.RegisterContract;
import com.cf.mvp.sample.mvp.presenter.MainPresenter;
import com.cf.mvp.sample.mvp.presenter.RegisterPresenter;


@Presenter(MainPresenter.class)
public class MainView extends BaseView<MainContract.Presenter> implements MainContract.View, RegisterContract.View {

    @FunPresenter(RegisterPresenter.class)
    private RegisterContract.Presenter presenter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getPresenter().login("admin", "1234567");
    }

    @Override
    public void loginSuccess() {
        System.out.println("登录成功");
    }

    @Override
    public void loginFailed() {
        System.out.println("登录失败");
        onDestroy();
    }


    public static void main(String[] args) {
        new Thread(new Runnable() {
            @Override
            public void run() {
                MainView view = new MainView();
                view.onCreate(null);
//                view.onDestroy();
            }
        }, "main").start();
    }

    @Override
    public void registerSuccess() {
        System.out.println("注册成功");
    }
}
